home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / nhost.arc / NCONFIG.SLT < prev    next >
Text File  |  1989-10-08  |  4KB  |  189 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   N E W H O S T .  S L T
  4. //
  5. //   Copyright (C) 1988 PTel and Colin Sampaleanu
  6. //
  7. //   This is a Host Mode configuration script for Telix.
  8. //   It reads form and saves parameters to the file NHOST.CNF,
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. // Revised by Jon Fleming (BIX: jfleming) 11/25/88 to go along with
  13. //    NEWHOST.SLT, which maintains individual passwords for users with
  14. //    an access level for each user; so the multiple level password required
  15. //    by the original HOST.SLT file are not required.
  16.  
  17. str host_downloads[64], host_uploads[64];    
  18. int direct_connect = 0;
  19. int f = 0;
  20.  
  21. //////////////////////////////////////////////////////////////////////////////
  22.  
  23. main()
  24.  
  25. {
  26.  
  27.  read_host_config_file();
  28.  host_configure();
  29.  
  30. }
  31.  
  32. //////////////////////////////////////////////////////////////////////////////
  33.  
  34. read_host_config_file()
  35.  
  36. {
  37.  str s[80];
  38.  int f, stat;
  39.  
  40.  s = _telix_dir;
  41.  strcat(s, "NHOST.CNF");
  42.  
  43.  f = fopen(s, "r");
  44.  if (!f)
  45.   {
  46.    printsc("Can't open ");
  47.    prints(s);
  48.    return -1;
  49.   }
  50.  
  51.  stat = fgets(s, 80, f);
  52.  if (stat == -1)
  53.   goto got_error;
  54.  host_downloads = s;
  55.  
  56.  stat = fgets(s, 80, f);
  57.  if (stat == -1)
  58.   goto got_error;
  59.  host_uploads = s;
  60.  
  61.  stat = fgets(s, 80, f);
  62.  if (stat == -1)
  63.   goto got_error;
  64.  direct_connect = (toupper(subchr(s, 0)) == 'D');
  65.  
  66.  fclose(f);
  67.  return 1;
  68.  
  69. // jump here if error
  70.  
  71.  got_error:
  72.   fclose(f);
  73.   return -1;
  74.  
  75. }
  76.  
  77. //////////////////////////////////////////////////////////////////////////////
  78.  
  79. host_configure()
  80.  
  81. {
  82.  str s[100];
  83.  int c, f, i, stat;
  84.  
  85.  if (!host_downloads)
  86.   {
  87.    host_downloads = _telix_dir;
  88.    strcat(host_downloads, "HSTFILES\");
  89.   }
  90.  
  91.  if (!host_uploads)
  92.   {
  93.    host_uploads = _telix_dir;
  94.    strcat(host_uploads, "HSTFILES\");
  95.   }
  96.  
  97.  while (1)
  98.   {
  99.    prints("^M^JNCONFIG - Host Mode Configuration Script^M^J");
  100.    printsc("A: Host download directory: ");
  101.    prints(host_downloads);
  102.    printsc("B: Host upload directory  : ");
  103.    prints(host_uploads);
  104.    printsc("C: Connection type        : ");
  105.    if (direct_connect)
  106.     prints("Direct");
  107.    else
  108.     prints("Modem");
  109.  
  110.    prints("^M^JD: Exit without saving changes.");
  111.    prints("E: Exit and save changes to disk.^M^J");
  112.  
  113.    printsc("Which option? ");
  114.    gets(s, 1);
  115.    prints("");
  116.    c = toupper(subchr(s, 0));
  117.    if (c < 'A' || c > 'E')
  118.     continue;
  119.  
  120.    if (c >= 'A' && c <= 'C')
  121.     printsc("Enter 
  122. new value (Esc to abort): ");
  123.  
  124.    if (c == 'A')
  125.     {
  126.      stat = gets(s, 48);
  127.      if (stat != -1)
  128.       {
  129.        host_downloads = s;
  130.        strupper(host_downloads);
  131.       }
  132.      if ((i = strlen(host_downloads)) != 0)       // add slash if needed
  133.       if (subchr(host_downloads, i - 1) != '\')
  134.        copystr("\", host_downloads, i, 1);
  135.     }
  136.    else if (c == 'B')
  137.     {
  138.      stat = gets(s, 48);
  139.      if (stat != -1)
  140.       {
  141.        host_uploads = s;
  142.        strupper(host_uploads);
  143.       }
  144.      if ((i = strlen(host_uploads)) != 0)
  145.       if (subchr(host_uploads, i - 1) != '\')
  146.        copystr("\", host_uploads, i, 1);
  147.     }
  148.    else if (c == 'C')
  149.     {
  150.      stat = gets(s, 7);
  151.      if (stat != -1)
  152.       direct_connect = (toupper(subchr(s, 0)) == 'D');
  153.     }
  154.  
  155.    else if (c == 'D')
  156.     {
  157.      prints("^M^JNCONFIG done.^M^J");
  158.      return;
  159.     }
  160.    else if (c == 'E')
  161.     {
  162.      s = _telix_dir;
  163.      strcat(s, "NHOST.CNF");
  164.      f = fopen(s, "w");
  165.  
  166.      if (!f)
  167.       {
  168.        printsc("Error writing to ");
  169.        printsc(s);
  170.        prints("!");
  171.        continue;
  172.       }
  173.  
  174.      fputs(host_downloads, f);
  175.      fputs("^M^J", f);
  176.      fputs(host_uploads, f);
  177.      fputs("^M^J", f);
  178.      if (direct_connect)
  179.       fputs("Direct^M^J", f);
  180.      else
  181.       fputs("Modem^M^J", f);
  182.  
  183.      prints("^M^JNCONFIG done.^M^J");
  184.      fclose(f);
  185.      return;
  186.     }
  187.   }
  188. }
  189.